using System;

namespace SeaVM.Instructions
{
    public class Define
    {
        public static Instruction Create(string name,int address)
        {
            Instruction inst = new Instruction();
            inst.opcode = Opcode.Define;
            InstructionArg arg1 = new InstructionArg();
            arg1.type = InstructionArgType.Define;
            arg1.define = name;
            inst.args.Add(arg1);
            InstructionArg arg2 = new InstructionArg();
            arg2.type = InstructionArgType.Address;
            arg2.address = address;
            inst.args.Add(arg2);
            return inst;
        }

        public static void Run(VM vm,Instruction inst)
        {
            vm.defines[inst.args[0].define] = inst.args[1].address;
            vm.line++;
        }
    }
}